import Vue from 'vue'
import VueRouter from 'vue-router'
// import HomeView from '../views/HomeView.vue'

Vue.use(VueRouter)
// 1、定义多个一级路由
const routes = [
  {
    path: '/index',
    name: 'index',
    component: () => import('../views/Index.vue'),

        children:[   //嵌套路由（二级路由）
          {
            path: '/index/home',  //路由地址
            name: 'home', //路由名称
            component: () => import('../views/Index/Home.vue') //地址对应的路由组件
          },
          {
            path: '/index/order',  //路由地址
            name: 'home', //路由名称
            component: () => import('../views/Index/Order.vue') //地址对应的路由组件
          },
           {
            path: '/index/mine',  //路由地址
            name: 'mine', //路由名称
            component: () => import('../views/Index/Mine.vue') //地址对应的路由组件
          },
          {
            path: '/index/bbt',  //路由地址
            name: 'bbt', //路由名称
            component: () => import('../views/Index/BBT.vue') //地址对应的路由组件
          },
          {
            //设置二级路由重定向
            path:'/index/',
            redirect:'/index/home'

          },
         {
        path:'*',
        component: () => import('../views/NotFound.vue') 
      }
         
    ]
  },

  {
    path: '/login',  //路由地址
    name: 'login', //路由名称
    component: () => import('../views/Login.vue') //地址对应的路由组件
  },
  {
    path: '/detail:name',  //路由地址
    name: 'detail', //路由名称
    component: () => import('../views/Detail.vue') //地址对应的路由组件
  },
  {
    // 设置一级路由重定向
    path:'/',
    redirect:'/index'
  },
  //404路由
  {
    path:'*',
    component: () => import('../views/NotFound.vue') 


  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
